package com.kgc.config;

import com.kgc.interceptor.UserCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    private final UserCheckInterceptor userCheckInterceptor;

    @Autowired
    public MyMvcConfig(UserCheckInterceptor userCheckInterceptor) {
        this.userCheckInterceptor = userCheckInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userCheckInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/user/login", "/user/register", "/category/pageInfoCategory", "/news/pageInfoNews", "/news/page", "zfb/**"
                        , "/product/getProductById"
                        , "/product/getCategoryByProductId", "/wx/**", "/product/page", "/news/page", "/news/getNewsDetail");
    }

}
